// eslint-disable-next-line
import { BasicLayout, BlankLayout, PageView, UserLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

/**
 * 菜单所需要的字段
 * @type {*[]}
 * path
 * meta : {
 *   title: '首页',
 *   keepAlive: true,
 *   icon: bxAnaalyse
 * }
 * hidden: 可以在菜单中不展示这个路由，包括子路由
 * hideChildrenInMenu: 隐藏不需要在菜单中展示的子路由
 * children: [
 *
 * ]
 *
 */
export const asyncRouterMap = [

  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '首页' },
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/analysis',
        hidden: true,
        component: PageView,
        meta: { title: '仪表盘', keepAlive: true, icon: bxAnaalyse },
        children: [
          {
            path: 'analysis',
            name: 'Analysis',
            component: () => import('@/views/dashboard/Analysis'),
            meta: { title: '工作台', keepAlive: false }
          },
          {
            path: 'changelog',
            name: 'changeLog',
            component: () => import('@/views/dashboard/ChangeLog'),
            meta: { title: '升级日志', keepAlive: false }
          }
        ]
      },
      {
        path: '/upms',
        name: 'upms',
        component: PageView,
        meta: { title: '权限管理', keepAlive: true, permission: ['admin'], icon: 'safety-certificate' },
        children: [
          {
            path: 'user',
            name: 'user',
            component: () => import('@/views/modules/sys/user/userList'),
            meta: { title: '用户管理', keepAlive: true, permission: ['admin:user'] }
          },
          {
            path: 'menu',
            name: 'menu',
            component: () => import('@/views/modules/sys/menu/menu'),
            meta: { title: '权限管理', keepAlive: true, permission: ['admin:permission'] }
          },
          {
            path: 'role',
            name: 'role',
            component: () => import('@/views/modules/sys/role/role'),
            meta: { title: '角色管理', keepAlive: true, permission: ['admin:role'] }
          },
          {
            path: 'dept',
            name: 'dept',
            component: () => import('@/views/modules/sys/dept/dept'),
            meta: { title: '部门管理', keepAlive: true, permission: ['admin:dept'] }
          },
          {
            path: 'post',
            name: 'post',
            component: () => import('@/views/modules/sys/post'),
            meta: { title: '岗位管理', keepAlive: true, permission: ['admin:post'] }
          }
        ]
      },
      {
        path: '/sys',
        name: 'sys',
        component: PageView,
        meta: { title: '系统管理', keepAlive: true, permission: ['sys'], icon: 'setting' },
        children: [
          {
            path: 'dict',
            name: 'dict',
            component: () => import('@/views/modules/sys/dict/dict'),
            meta: { title: '数据字典', keepAlive: true, permission: ['sys:dict'] }
          },
          {
            path: 'config',
            name: 'config',
            component: () => import('@/views/modules/sys/config'),
            meta: { title: '参数配置', keepAlive: true, permission: ['sys:config'] }
          },
          {
            path: 'configUser',
            name: 'configUser',
            component: () => import('@/views/modules/sys/configUser'),
            meta: { title: '用户参数配置', keepAlive: true, permission: ['sys:configUser'] }
          },
          {
            path: 'client',
            name: 'client',
            component: () => import('@/views/modules/sys/client/client'),
            meta: { title: '终端管理', keepAlive: true, permission: ['sys:client'] }
          },
          {
            path: 'token',
            name: 'token',
            component: () => import('@/views/modules/sys/token'),
            meta: { title: '令牌管理', keepAlive: true, permission: ['sys:token'] }
          },
          {
            path: 'social',
            name: 'social',
            component: () => import('@/views/modules/sys/social/social'),
            meta: { title: '密钥管理', keepAlive: true, permission: ['sys:social'] }
          },
          {
            path: 'storage',
            name: 'storage',
            component: () => import('@/views/modules/file/index'),
            meta: { title: '文件管理', keepAlive: true }
          }
        ]
      },
      {
        path: '/message',
        name: 'message',
        meta: { title: '消息中心', icon: 'fund' },
        component: PageView,
        children: [
          {
            path: 'template',
            name: 'template',
            component: () => import('@/views/modules/message/template'),
            meta: { title: '消息模板', keepAlive: true }
          },
          {
            path: 'sendLog',
            name: 'sendLog',
            component: () => import('@/views/modules/message/SendLog/tableList'),
            meta: { title: '历史消息', keepAlive: true }
          },
          {
            path: 'notice',
            name: 'notice',
            component: () => import('@/views/modules/message/NoticeInfo/NoticeInfoList'),
            meta: { title: '我的消息', keepAlive: true }
          }
        ]
      },
      {
        meta: { title: '系统监控', icon: 'fund' },
        component: BlankLayout,
        path: '/visual',
        name: 'visual',
        children: [
          {
            path: process.env.VUE_APP_API_BASE_URL + '/doc.html',
            name: 'swagger',
            meta: { title: '接口文档', target: '_blank' }
          }
        ]
      },
      {
        path: '/app',
        name: 'app',
        component: PageView,
        meta: { title: 'app管理', keepAlive: true, icon: 'setting' },
        children: [
          {
            path: 'version',
            name: 'version',
            component: () => import('@/views/modules/app/version'),
            meta: { title: '版本管理', keepAlive: true }
          },
          {
            path: 'create',
            name: 'create',
            component: () => import('@/views/modules/app/create-app'),
            meta: { title: '上传app', keepAlive: true }
          }
        ]
      },
      {
        path: '/dynamicForm',
        name: 'dynamicForm',
        component: PageView,
        meta: { title: '表单管理', keepAlive: true, icon: 'setting' },
        children: [
          {
            path: 'design',
            name: 'design',
            component: () => import('@/views/modules/dynamicForm/design'),
            meta: { title: '设计表单', keepAlive: true }
          },
          {
            path: 'formData/:formCode',
            name: 'formData',
            hidden: true,
            component: () => import('@/views/modules/dynamicForm/data'),
            meta: { title: '表单数据', keepAlive: true }
          }
        ]
      },
      {
        path: '/online',
        name: 'online',
        hidden: true,
        component: PageView,
        meta: { title: '在线开发', keepAlive: true, icon: 'setting' },
        children: [
          {
            path: 'form',
            name: 'form',
            component: () => import('@/views/modules/form/head'),
            meta: { title: '在线表单开发', keepAlive: true }
          }
        ]
      },
      // account
      {
        path: '/account',
        component: PageView,
        redirect: '/account/center',
        name: 'account',
        hideChildrenInMenu: true,
        hidden: true,
        meta: { title: '个人页', icon: 'user', keepAlive: true },
        children: [
          {
            path: '/account/settings',
            name: 'settings',
            component: () => import('@/views/account/settings/Index'),
            meta: { title: '个人设置', hideHeader: true },
            redirect: '/account/settings/base',
            children: [
              {
                path: '/account/settings/base',
                name: 'BaseSettings',
                component: () => import('@/views/account/settings/BaseSetting'),
                meta: { title: '基本设置', hidden: true }
              },
              {
                path: '/account/settings/custom',
                name: 'CustomSettings',
                component: () => import('@/views/account/settings/Custom'),
                meta: { title: '个性化设置', hidden: true, keepAlive: true }
              },
              {
                path: '/account/settings/Binding',
                name: 'BindingSettings',
                component: () => import('@/views/account/settings/Binding'),
                meta: { title: '账户绑定', hidden: true, keepAlive: true }
              }
            ]
          }
        ]
      },
      {
        path: '/example',
        name: 'example',
        hidden: true,
        component: PageView,
        meta: { title: '示例', keepAlive: true, icon: 'setting' },
        children: [
          {
            path: 'input_box_index',
            name: 'input_box_index',
            component: () => import('@/views/example/input_box/Index'),
            meta: { title: '输入框', keepAlive: true }
          },
          {
            path: 'select_box_index',
            name: 'select_box_index',
            component: () => import('@/views/example/select_box/Index'),
            meta: { title: '选择框', keepAlive: true }
          },
          {
            path: 'upload_box_index',
            name: 'upload_box_index',
            component: () => import('@/views/example/upload_box/Index'),
            meta: { title: '上传', keepAlive: true }
          },
          {
            path: 'table_index',
            name: 'table_index',
            component: () => import('@/views/example/table/Index'),
            meta: { title: '表格', keepAlive: true }
          },
          {
            path: 'form_index',
            name: 'form_index',
            component: () => import('@/views/example/form/Index'),
            meta: { title: '表单', keepAlive: true }
          },
          {
            path: 'style_index',
            name: 'style_index',
            component: () => import('@/views/example/style/Index'),
            meta: { title: '排列样式', keepAlive: true }
          },
          {
            path: 'select_table_index',
            name: 'select_table_index',
            component: () => import('@/views/example/select_table_index/index'),
            meta: { title: '选择表格', keepAlive: true }
          }
        ]
      },
      // cms
      {
        path: '/cms',
        name: 'cms',
        component: PageView,
        meta: { title: '内容管理', icon: 'slack' },
        children: [
          {
            path: 'category',
            name: 'category',
            component: () => import('@/views/modules/cms/category/category'),
            meta: { title: '分类目录', keepAlive: true, icon: 'security-scan' }
          },
          {
            path: 'menus',
            name: 'menus',
            component: () => import('@/views/modules/cms/menus/menus'),
            meta: { title: '菜单', keepAlive: true, icon: 'security-scan' }
          }
        ]
      }
    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/page/login')
      }
    ]
  },
  {
    path: '/authredirect',
    name: 'authredirect',
    component: () => import('@/page/authredirect')
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  },
  {
    path: '/design/form/:id',
    name: 'dynamicForm',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/modules/dynamicForm/design/designForm')
  }
]
